package main

import (
	"context"
	"fmt"
	"log"
	"time"

	"gitee.com/kratos-learning/service-register-discovery/grpc/pb"
	"google.golang.org/grpc"
)

func main() {
	conn, err := grpc.Dial("localhost:1234", grpc.WithInsecure())
	if err != nil {
		log.Fatal(err)
	}
	defer conn.Close()

	client := pb.NewHelloServiceClient(conn)

	conn2, err := grpc.Dial("localhost:12345", grpc.WithInsecure())
	if err != nil {
		log.Fatal(err)
	}
	defer conn.Close()

	client2 := pb.NewHelloServiceClient(conn2)
	for i := 1; i <= 5; i++ {
		reply, err := client.Hello(context.Background(), &pb.String{Value: "龚凌锋"})
		if err != nil {
			log.Fatal(err)
		}
		fmt.Println(reply.GetValue())

		reply2, err := client2.Hello(context.Background(), &pb.String{Value: "龚凌锋2"})
		if err != nil {
			log.Fatal(err)
		}
		fmt.Println(reply2.GetValue())
		time.Sleep(10 * time.Second)
	}

}
